﻿<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">

    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />



    <link rel="stylesheet" href="../content/css/font.css">
    <link rel="stylesheet" href="../content/css/xadmin.css">
    <link rel="stylesheet" href="../content/plugin/bootstrap/css/bootstrap.min.css">
    <link rel='stylesheet' href='../content/plugin/bootstrap/css/style.css' />

    <script src="../content/js/jquery-1.10.2.min.js"></script>

    <script type="text/javascript" src="../content/js/xadmin.js"></script>
    <script type="text/javascript" src="../content/js/md5.min.js"></script>
    <script type="text/javascript" src="../content/js/cookie.js"></script>
    <script src="../content/lib/layui/layui.js" charset="utf-8"></script>
    <link rel="stylesheet" href="../content/plugin/FileUpload/css/jquery.fileupload.css" />




</head>

<body>
    <div id="app">
        <div class="x-nav">

            <span class="nav-header">
                <a href="">首页</a>>
                <a href="">商品管理</a>>
                <a>
                    <cite>秒杀</cite>
                </a>
            </span>

        </div>
        <div class="x-body">



            <div class="table-responsive">
                <table class="table">
                    <thead>
                        <tr>


                            <th> 时间段</th>
                            <th> 商品</th>

                            <th>操作</th>

                        </tr>
                    </thead>
                    <tbody>
                        <tr v-for="uitem in arrayData">



                            <td>{{uitem.time}}</td>
                            <td>

                                <table class="table">
                                    <tr>
                                        <td>商品名称</td>
                                        <td>商品图片</td>
                                        <td>排序</td>
                                        <td>折扣</td>
                                        <td>操作</td>
                                    </tr>
                                    <tr v-for="item in uitem.goodlist">
                                        <td>{{item.goods_name}}</td>
                                        <td>
                                            <img :src="item.imgurl" style="width:50px" />
                                        </td>
                                        <td>
                                            <input type="number" value="" v-model="item.seq" @input="seqchange(item)"
                                                style="width: 50px;" />
                                        </td>
                                        <td>
                                            <input type="number" value="" v-model="item.zhekou" @input="seqchange(item)"
                                                style="width: 50px;" />
                                        </td>
                                        <td>
                                            <a title="" v-on:click="vdel(item)" href="javascript:;">
                                                删除商品
                                            </a>
                                        </td>
                                    </tr>
                                </table>
                            </td>




                            <td class="td-manage">

                                <a title="编辑" v-on:click="choosegood(uitem)" href="javascript:;">
                                    添加商品
                                </a>

                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>

        </div>





    </div>
    <link href="../content/plugin/sweetalert/sweetalert.css" rel="stylesheet">
    <script src="../content/plugin/sweetalert/sweetalert.min.js"></script>
    <script src="../content/plugin/bootstrap/js/bootstrap.min.js"></script>
    <script src="../content/js/vue2.js"></script>
    <script src="../content/js/vue-nav.js"></script>
    <script src="../content/js/config.js"></script>

    <script>


        Array.prototype.remove = function (val) {
            var index = this.indexOf(val);
            if (index > -1) {
                this.splice(index, 1);
            }
        };
        var vm = new Vue({
            el: "#app",
            data: {
                all: 0,
                search: {
                    page: 1,
                    size: 10
                },
                arrayData: [],
                allcount: 0,
                menulist: [],
                addobj: {
                    parentid: 0
                },
                editobj: {},
                datalist: [],
                statelist: [{ "id": 1, "name": "是" }, { "id": 0, "name": "否" }],
                typelist: [{ "id": "1", "name": "C端" }, { "id": "2", "name": "B端" }, { "id": "1,2", "name": "BC端" }],
            },
            components: {
                'vue-nav': Vnav
            },
            methods: {
                searchdata: function () {
                    this.search.page = 1;
                    this.getdata();
                },

                add: function () {
                    location.href = "add.html";
                },
                addhang: function () {
                    if (this.datalist == null) {
                        this.datalist = [];
                    }
                    console.log("addhang", this.datalist);
                    var datalist = this.datalist;
                    datalist.push({});
                    this.datalist = datalist;
                },
                insert: function (addobj) {
                    var self = this;
                    addobj.id = "";
                    this.addobj.datalist = "";
                    //  this.addobj.token = json.token;
                    $.post(apiurl + "/admin/menu/add", addobj, function (data) {
                        if (data.status == 200) {
                            $("#addbox").modal('hide');
                            swal("success", "添加成功", "success");
                            self.getdata("");
                        } else {
                            swal("系统提示", data.message, "error");
                        }

                    });
                },
                choosegood: function (uitem) {

                    x_admin_show('选择商品', 'goods.html?time=' + uitem.time, 800, 620)
                },
                getdata: function (_keycontent) {  //查询数据

                    var _this = this;
                    $.post(apiurl + "/admin/seckill/list", {}, function (_result) {
                        console.log(_result);
                        var data = _result.data;
                        _this.arrayData = data;


                    });
                },

                vupdate: function (uitem) {

                    location.href = "edit.html?id=" + uitem.id;

                },

                vdel: function (uitem) {


                    var self = this;
                    swal({
                        title: "确定要删除吗?",
                        text: "",
                        type: "warning",
                        showCancelButton: true,
                        confirmButtonColor: "#DD6B55",
                        confirmButtonText: "是",
                        cancelButtonText: '否',
                        closeOnConfirm: false
                    }, function () {

                        $.ajax({
                            url: apiurl + '/admin/seckill/del',
                            type: 'DELETE',
                            data: { "ids": uitem.id },
                            success: function (result) {
                                if (result.status == 200) {
                                    swal("系统提示", "已清除", "success");
                                    self.getdata("");
                                } else {
                                    swal("系统提示", "系统异常", "success");
                                }
                            }
                        });

                    });
                },
                seqchange: function (uitem) {
                    var self = this;

                    $.post(apiurl + "/admin/seckill/edit", uitem, function (data) {
                        if (data.status == 200) {
                            self.getdata("");
                        } else {

                        }
                    });
                }

            },
            created: function () {  //初始化事件里边去调用查询方法
                this.getdata("");



            }
        });


    </script>
</body>

</html>